<template>
  <div class="box">
    <div class="item" @click='clickItem(item.id)' v-for="item in items" :key="item.id">
      <img
       v-lazy="item.pic" alt=""
        class="item-pic"
       
      /><!-- lazy懒加载 -->
      <span class="text">
        <img
          src="https://img10.360buyimg.com/jdphoto/jfs/t1/67472/23/16111/1062/5dd66228Ed3249693/c561eee12d153d56.png"
          alt=""
          class="ziying"
        />样样十元通通十元走过路过不要错过机会只有一次，珍惜每一次机会</span
      >
      <div class="jiage">
       <span class="price">￥ {{item.minPrice}}</span>
       <span class="manjian">满减</span>
       <van-icon @click.stop="clickCartIcon(item.id)" name="xiazai1" size="20" class-prefix="icon"></van-icon>
       <span class="about">看相似</span>
       
     </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickItem(id){
      this.$emit('clickItem',id)//点击商品触发事件到父组件
    },
     clickCartIcon (id) {
      this.$emit('addCart', id)
    }
  },
}
</script>

<style lang="scss" scoped>
.box {
  margin-top: 40px;
  display: flex;
  justify-content: space-around;
    flex-wrap: wrap;
}
.item {
  width: 50%;
  text-align: center;
}
.item-pic {
 width: 95%;
  border-radius: 15px 15px 0 0;
  height: 10.7297rem;
}
.ziying {
  width: 1.3946rem;
  margin-right: 4px;
  height: 0.9054rem;
}
.icon-xiazai1{
  font-size: 17px;
  color: red;
}
.text {
  margin-left: 10px;
  width: 190px;
  height: 35px;
  font-size: 13px;
overflow: hidden;
display: -webkit-box;
margin-left: 8px;
-webkit-box-orient: vertical;

-webkit-line-clamp: 2;

-ms-text-overflow: ellipsis;

text-overflow: ellipsis;
}
.price{
  color: #fa2c19;
  margin-right: 50px;
    font-weight: 600;
}
.jiage{
width: 100%;
height: 30px;
padding-right: 20px;
text-align: center;
}
.manjian{
  border: 2px solid red;
  border-radius: 5px;
  color: #fa2c19;
  font-size: 12px;
  position: relative;
  right: 45px;
  padding: 0.027rem;
}
.about{
  color: grey;
  font-size: 0.6351rem;border: 1px solid gray;
  border-radius: 10px 10px;
  padding: 1px;
  position: relative;
  right: -20px;
  background: rgb(219, 217, 217);

}
</style>
